package top.tangyh.lamp.msg.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author: zqb
 * @date: 2024/6/25 08:28
 */
public class Test {
    public static void main(String[] args) {
//        List<Integer> list = List.of(1, 2, 3, 4, 5, 6, 7);
//        List<Integer> takenList = list.stream().takeWhile(number -> number < 5).collect(Collectors.toList());
//        System.out.println(takenList);
//
//        List<Integer> dropedList = list.stream().dropWhile(number -> number < 5).collect(Collectors.toList());
//        System.out.println(dropedList);

//        List<String> list = List.of("apple", "banana", "orange");
//        String joinedString = list.stream().collect(Collectors.joining("-", "[", "]"));
//        System.out.println(joinedString);
//
//        Map<String, Integer> map = Map.of("apple", 1, "banana", 2, "orange", 3);
//        Map<Integer, String> reversedMap = map.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
//        System.out.println(reversedMap);

        List<String> list = List.of("apple", "banana", "orange");
        String[] array = list.toArray(String[]::new);
        System.out.println(Arrays.toString(array));
    }
}
